<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<title>redis-签到示例代码</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <link rel="stylesheet" type="text/css" th:href="@{/css/sign2.css}">

    <script type="text/javascript" th:src="@{/js/jquery-1.8.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/calendar2.js?a=1}"></script>
    <script th:inline="javascript" type="text/javascript">
        $(function(){
            //ajax获取日历json数据
            //const signList=[{"signDay":"09"},{"signDay":"11"},{"signDay":"12"},{"signDay":"13"}];
            
         $.ajax({
		url: "/redis-producer/getSign",
	    type: "GET",
	    //data:signsList,
	    success:function(data){
	    	
	    	if(data=="sign"){
	    		const signList = [];
	    		calUtil.init(signList);
	    	}else{
	    		const signList = data;
		    	calUtil.init(signList);
	    	}
	    	
	    },
	    error:function(){
	    	alert("错误");
	    }
	});  
            
         /* if([[${redis_object}]] != null ){
        	 var str = [[${redis_object}]];
        	 str = str.replace();
        	 alert(str);
            	const signList= str;
            	calUtil.init(signList);
            }else{
            	const signList=[];
            	calUtil.init(signList);
            } 
             */
           /*  const signList=[{"signDay":"09"},{"signDay":"11"},{"signDay":"12"},{"signDay":"13"}];
            calUtil.init(signList); */
            

            $("#calendar").click(function(e){
                const day=e.target.innerHTML;//获取当前点击对象的html,其实就是  天

                fetch("/redis-producer/signapi",{
                     method:"POST"
                    ,body:"day="+day
                    ,headers:{
                         'Content-type':'application/x-www-form-urlencoded'
                    }
                  })
                    .then(function(result){
                        result.text().then(function(data){
                            //得到返回值，你爱咋处理咋处理
                        })
                    });

            })
        });
    </script>
	
</head>
<body>
	<div style="" id="calendar"></div>
</body>
</html>